package com.EAIPClub.userdatamanager.mapper;

import com.api.POJO.UserDataManager.Data.UserPrivileges;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @Description :用户权限信息Mapper
 * @Author :崔昌赫
 * @Date : 2021/10/11
 */
@Mapper
@Repository
public interface UserPrivilegesDataMapper {
    @Select("SELECT * FROM user_privileges")
    List<UserPrivileges> findAllUserPrivilegesData();
    @Select("SELECT * FROM user_privileges WHERE uid='${uid}'")
    UserPrivileges findUserUserPrivilegesDataByUid(@Param("uid") String uid);
    @Select("SELECT * FROM user_privileges WHERE codeIde='${codeIde}'")
    List<UserPrivileges> findUserPrivilegesDataByCodeIde(@Param("codeIde") Integer codeIde);
    @Select("SELECT * FROM user_privileges WHERE codeShell='${codeShell}'")
    List<UserPrivileges> findUserPrivilegesDataByCodeShell(@Param("codeShell") Integer codeShell);
    @Select("SELECT * FROM user_privileges WHERE codeDesktop='${codeDesktop}'")
    List<UserPrivileges> findUserPrivilegesDataByCodeDesktop(@Param("codeDesktop") Integer codeDesktop);

    @Insert("INSERT INTO user_privileges VALUES ('${userPrivileges.uid}','${userPrivileges.codeIde}','${userPrivileges.codeShell}','${userPrivileges.codeDesktop}')")
    Boolean addUserIntoUserPrivilegesData(@Param("userPrivileges") UserPrivileges userPrivileges);

    @Update("UPDATE user_privileges SET uid = '${nuid}' WHERE uid='${uid}'")
    Boolean updateUserPrivilegesDataUidByUid(@Param("nuid")String nuid,@Param("uid")String uid);
    @Update("UPDATE user_privileges SET codeIde = '${codeIde}' WHERE uid='${uid}'")
    Boolean updateUserPrivilegesDataCodeIdeByUid(@Param("codeIde")Integer codeIde,@Param("uid")String uid);
    @Update("UPDATE user_privileges SET codeShell = '${codeShell}' WHERE uid='${uid}'")
    Boolean updateUserPrivilegesDataCodeShellByUid(@Param("codeShell")Integer codeShell,@Param("uid")String uid);
    @Update("UPDATE user_privileges SET codeDesktop = '${codeDesktop}' WHERE uid='${uid}'")
    Boolean updateUserPrivilegesDataCodeDesktopByUid(@Param("codeDesktop")Integer codeShell,@Param("uid")String uid);

    @Delete("DELETE FROM user_privileges WHERE uid='${uid}'")
    Boolean deleteUserPrivilegesDataByUid(@Param("uid")String uid);

}
